package com.ruoyi.quartz.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import javax.annotation.PostConstruct;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Configuration
@ConfigurationProperties(prefix = "tts.yaml")
@Validated
public class YamlConfigProperties {

    @NotBlank(message = "baseDir 不能为空")
    private String baseDir;

    @NotBlank(message = "filePrefix 不能为空")
    private String filePrefix;

    @NotBlank(message = "fileSuffix 不能为空")
    private String fileSuffix;

    @NotNull(message = "fileHeader 不能为空")
    private String fileHeader;

    @NotBlank(message = "mediaParams 不能为空")
    private String mediaParams;

    @NotBlank(message = "generationCron 不能为空")
    private String generationCron;

    private int retentionDays = 7; // 默认保留7天

    // Getter 和 Setter
    public String getBaseDir() {
        return baseDir;
    }

    public void setBaseDir(String baseDir) {
        this.baseDir = baseDir;
    }

    public String getFilePrefix() {
        return filePrefix;
    }

    public void setFilePrefix(String filePrefix) {
        this.filePrefix = filePrefix;
    }

    public String getFileSuffix() {
        return fileSuffix;
    }

    public void setFileSuffix(String fileSuffix) {
        this.fileSuffix = fileSuffix;
    }

    public String getFileHeader() {
        return fileHeader;
    }

    public void setFileHeader(String fileHeader) {
        this.fileHeader = fileHeader;
    }

    public String getMediaParams() {
        return mediaParams;
    }

    public void setMediaParams(String mediaParams) {
        this.mediaParams = mediaParams;
    }

    public String getGenerationCron() {
        return generationCron;
    }

    public void setGenerationCron(String generationCron) {
        this.generationCron = generationCron;
    }

    public int getRetentionDays() {
        return retentionDays;
    }

    public void setRetentionDays(int retentionDays) {
        this.retentionDays = retentionDays;
    }

    @PostConstruct
    public void validate() {
        if (!fileSuffix.startsWith(".")) {
            throw new IllegalArgumentException("fileSuffix 必须以点号开头");
        }
    }
}